package top.cyuw.subjectsystem.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
public class ImportResultVo extends BaseVo {

    /**
     * 成功导入条数
     */
    private Integer success;

    /**
     * 失败导入条数
     */
    private Integer error;

    /**
     * 错误提示
     */
    private List<String> errorMsgs;

    public void incSuccess() {
        if (success == null) {
            success = 0;
        }
        success += 1;
    }

    private void incError() {
        if (error == null) {
            error = 0;
        }
        error += 1;
    }

    public void addError(String msg) {
        incError();
        errorMsgs.add(msg);
    }

    public static ImportResultVo create() {
        return new ImportResultVo(0, 0, new ArrayList<>());
    }

}
